package com.content.controller
{
	import com.content.AppFacade;
	import com.content.model.GlobalVarProxy;
	import com.content.model.LoadedAssets.ConfigProxy;
	import com.content.view.Frame.CBar.CBar;
	import com.content.view.Frame.Content.ContentMediator;
	import com.content.view.Frame.MainPanel.*;
	import com.content.view.Frame.MainPanel.MPCapacity.MPCapacity_Mediator;
	import com.content.view.Frame.MainPanel.MPDebug.MPDebug_Mediator;
	import com.content.view.Frame.MainPanel.MPHome.MPHome_Mediator;
	import com.content.view.Frame.MainPanel.MPMyShelf.MPMyShelf_Mediator;
	import com.content.view.Frame.MainPanel.MPOnlineResAudio.MPOnlineResAudio_Mediator;
	import com.content.view.Frame.MainPanel.MPOnlineResBook.MPOnlineResBook_Mediator;
	import com.content.view.Frame.MainPanel.MPOnlineResVideo.MPOnlineResVideo_Mediator;
	import com.content.view.Frame.MainPanel.MPPassword.MPPassword_Mediator;
	import com.content.view.Frame.MainPanel.MPUserInfo.MPUserInfo_Mediator;
	import com.library.utils.StringUtil;
	
	import flash.desktop.NativeApplication;
	
	import org.aswing.JOptionPane;
	import org.aswing.geom.IntDimension;
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;

	public class ContentCommand extends SimpleCommand implements ICommand
	{
	
		override public function execute(note:INotification):void
		{
			var name:String = note.getName();
			var body:Object = note.getBody();
			
			
			switch ( name )
			{
				case AppFacade.MAINPANEL_OPEN:
					var mpID:String = body["MPID"];
					switch(mpID){
						case MPCapacity_Mediator.NAME:
						case MPDebug_Mediator.NAME:
						case MPHome_Mediator.NAME:
						case MPMyShelf_Mediator.NAME:
						case MPOnlineResAudio_Mediator.NAME:
						case MPOnlineResBook_Mediator.NAME:
						case MPOnlineResVideo_Mediator.NAME:
						case MPPassword_Mediator.NAME:
						case MPUserInfo_Mediator.NAME:
							sendNotification(MPBase.SWITCH, {MPID: mpID});
							break;
						case "MPShutdown":
							var jop:JOptionPane = JOptionPane.showMessageDialog(
								"提示",
								"确认退出？",
								function(result:int):void{
									if(result == JOptionPane.YES){
										NativeApplication.nativeApplication.exit();
									}
								},
								null, true, null,
								JOptionPane.YES|JOptionPane.NO);
							jop.getFrame().setDefaultButton(jop.getYesButton());
							jop.getFrame().setSize(new IntDimension(200, 120));
							break;
					}
					break;
			}
		}
		
		private function get P_Config():ConfigProxy{return facade.retrieveProxy( ConfigProxy.NAME ) as ConfigProxy;}
		private function get P_GlobalVar():GlobalVarProxy{return facade.retrieveProxy( GlobalVarProxy.NAME ) as GlobalVarProxy;}
	}
}